package com.wms.controller;

import com.wms.dto.UserBackPageQueryDTO;
import com.wms.entity.WmsUserback;
import com.wms.result.PageResult;
import com.wms.result.Result;
import com.wms.service.UserBackService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/userback")
@Slf4j
@Api(tags = "用户反馈模块")
public class UserBackController {
    @Autowired
    private UserBackService userBackService;

    /**
     * 批量删除
     * @param ids
     * @return
     */
    @DeleteMapping("/delete")
    @ApiOperation("批量删除用户反馈")
    public Result delete(@RequestParam List<Integer> ids) {
        userBackService.delete(ids);
        return Result.success();
    }

    /**
     * 分页查询
     * @param userBackPageQueryDTO
     * @return
     */
    @PostMapping("/page")
    @ApiOperation("分页查询")
    public Result<PageResult> page(@RequestBody UserBackPageQueryDTO userBackPageQueryDTO) {
        log.info("当前页码:{},页面大小:{}", userBackPageQueryDTO.getPage(), userBackPageQueryDTO.getPageSize());
        PageResult pageResult = userBackService.page(userBackPageQueryDTO);
        log.info("pageResult:{}", pageResult);
        return Result.success(pageResult);
    }

    /**
     * 新增
     * @param wmsUserBack
     * @return
     */
    @PostMapping("/save")
    @ApiOperation("新增用户反馈")
    public Result save(@RequestBody WmsUserback wmsUserBack) {
        userBackService.save(wmsUserBack);
        return Result.success();
    }
}
